<?php

    class UrlParser{
	
	private $requested_url = NULL;
	
	function __construct(){
	    
	    $this->requested_url = ltrim($_SERVER['REQUEST_URI'],'/');
	    
	}
	
	function url_parsing(){
	    
	    if ($this->requested_url){
	    
		$parsed_url = explode('/',$this->requested_url);
		
		for($i=0;$i<count($parsed_url)-1;$i++){
		    
		    if ($parsed_url[$i] == '') $parsed_url[$i] = 0;
		    
		}
		
		return $parsed_url;
	    
	    }else{
		
		return array(0);
		
	    }
	    
	}
	
	function get_n_param($num){
	    
	    if ($num <= count($this->url_parsing())){
		
		$url = $this->url_parsing();
		return $url[$num-1];
		
	    }else{
		
		return 0;
		
	    }
	    
	}
	
	function __destruct(){
	    
	    
	    
	}
	
    }

?>